import hashlib
from faker import Faker
from allpairspy import AllPairs 



class TxtWriter:
    def __init__(self, file_path, mode='w', encoding='utf-8'):
        self.file_path = file_path
        self.mode = mode
        self.encoding = encoding

    def write_lines(self, lines):
        with open(self.file_path, self.mode, encoding=self.encoding) as f:
            for line in lines:
                f.write(f"{line}\n")


class DataGenerator:

	def __init__(self):
		self.faker = Faker(locale='zh_CN')
	

	def register_data(self, n):
		data = []

		for i in range(n):
			item = ""
			item += self.faker.user_name()
			item += ','
			byte_text = self.faker.password().encode('utf-8')
			item += hashlib.md5(byte_text).hexdigest()
			item += ',100'
			data.append(item)
		
		return data



if __name__ == '__main__':
	dg = DataGenerator()
	data = dg.register_data(500)
	tw = TxtWriter("C:/Users/YuNeko/Desktop/Buffer0/data1.txt")
	tw.write_lines(data)